﻿@{
    ViewBag.Title = "WXPay";
}

<div style="width:100%;font-size:16pt;color:#3C3C3C;height:40px;line-height:40px;vertical-align:middle;padding-left:20px;">
    收银台
</div>
<div style="width:100%;height:80px;background-color:#e6e6e6;padding:0;">
    <table style="width:100%;height:100%;margin:0;">
        <tr>
            <td style="vertical-align:bottom;padding-left:20px;width:50%;">
                订单编号：@ViewBag.OrderId
            </td>
            <td rowspan="2" style="text-align:right;padding-right:20px;">
                应付金额：￥@ViewBag.Money
            </td>
        </tr>
        <tr>
            <td style="vertical-align:top;padding-left:20px;">
                订单类型：@ViewBag.OrderType
            </td>
        </tr>
    </table>
</div>

<div style="margin-top:20px;margin-left:20px;width:570px;height:30px;line-height:30px;border:2px solid #f88204;margin-left:10px;vertical-align:middle">
    <img src="~/content/images/WePayLogo.png" width="72px" height="20px" style="margin-top:5px;margin-left:10px;float:left;"/>
    <img src="~/content/images/pushlogo.png" width="46px" height="20px"  style="margin-top:5px;margin-left:10px;float:left;"/>
    <span style="margin-left:5px;margin-top:0px;color:#808080;float:left;">亿万用户的选择，更快更安全</span>
    <div style="margin:0;margin-left:auto;height:30px;vertical-align:middle;padding-right:10px;float:right;">
        支付 <span style="color:#f88204;">@ViewBag.Money</span> 元
    </div>
</div>

<div style="width:100%;">
    <div style="margin-left:10px;margin-top:10px;width:100%;">
        <iframe id="FMPAY" name="FMPAY" src=""  frameborder=0 width=230 height=230 marginheight=0 marginwidth=0 scrolling=no ></iframe>
    </div>
    <div style="margin-left:10px;">
        <img src="~/content/images/descript.png" width="210px" height="69px"/>
    </div>
</div>
<input type="hidden" value="@ViewBag.OrderId" id="billno" />
<input type="hidden" value="@ViewBag.EntryID" id="EntryID" />
<input type="hidden" value="@ViewBag.Ass" id="Ass" />

<script>
    var billno = "";
    var appID = "";

    function Query() {
        var json = "[{";
        json = json + "'BillNo':'" + billno + "',";
        json = json + "'EntryID':'" + $("#EntryID").val() + "',";
        json = json + "'Type':'" + "1" + "',";
        json = json + "'mSystemAppID':'" + parent.window.getSystemAppID() + "'}]";
        //主动查询
        $.post("../AppCenter/QueryPay", { mjson: json }, function (data) {
        });
    }

    var timer1 = setInterval(function () {
        var json = "[{";
        json = json + "'BillNo':'" + billno + "',";
        json = json + "'EntryID':'" + $("#EntryID").val() + "',";
        json = json + "'Type':'" + "1" + "',";
        json = json + "'mSystemAppID':'" + appID + "'}]";
        $.post("getPayStatus", { mjson: json }, function (data) {
            var ret = mini.decode(data);
            if (ret.status == 1) {
                clearInterval(timer1);
                mini.alert("支付成功");
                window.opener = null;
                window.close();
            }
        });
    }, 1000);

    function setPage() {
        var data = {};
        data.mSystemAppID = GetQueryString("mSystemAppID");
        data.BillNo = GetQueryString("BillNo");
        data.TMoney = 0;
        appID = data.mSystemAppID;
        if (GetQueryString("TMoney") != null)
            data.TMoney = GetQueryString("TMoney");

        if (data.TMoney > 0)
            InitData(data);
    }

    window.onload = function () {
        var t = setTimeout("setPage()", 2000);
    }
    
    function SetData(data) {
        billno = $("#billno").val();
        $("#FMPAY").attr("src", "CustomPay?Ass=" + $("#Ass").val() + "&pos=" + data.selectinfo["LI001"]
            + "&BServer=" + data.selectinfo["LI002"] + "&WX=" + data.selectinfo["LI003"] + "&Num="
            + data.iNum + "&mSystemAppID=" + data.AppID + "&BillNo=" + billno);
        Query();
    }
    function InitData(data) {
        billno = data.BillNo;
        $("#FMPAY").attr("src", "CustomPay?mSystemAppID=" + data.mSystemAppID + "&TMoney=" + data.TMoney + "&BillNo=" + data.BillNo);
    }

    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }

</script>